Fix executor deadlock when IO doesn't support non-ascii characters #2721
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My environment happened to have a faulty locale setup and running
poetry install
got stuck for no apparent reason. This PR makes it so that the command doesn't get stuck in similar situations.How to repro against 1.1.0b2
Expected: fails with a nice error
Actual: gets stuck waiting for a
threading.Lock
to become available.strace:
Ctrl-C gets it unstuck, but the new package isn't installed (while it's added to pyproject.toml).
With this fix
Note: the expected output in the new test added by this PR includes information about the exception (the "Unicode\w+Error" part) because the
io
object used in tests doesn't support ansi.On the other hand, when the
io
object supports ansi andPYTHONIOENCODING=ascii
is set like in the case above, the exception handling code tries to write a message that contains a unicode character that cannot be encoded with ascii (•
), resulting in no information about the exception getting logged.PYTHONIOENCODING=ascii poetry add filetype | tee /dev/null
is one way to see the exception.A more thorough 'fix' for environments that don't support non-ascii characters might be to add a check for it somewhere earlier in the app, like click does. I'm leaving such changes out of this PR to keep it focused on fixing the deadlock and also because I'm not sure what the desired behavior would be (the app could exit with an error message, or it could switch to a non-ascii output format).
Pull Request Check List
Resolves: no corresponding issue